package com.zmn.plat.common.dictionary;

/**
 * 渠道类型
 *
 * @author xiangjunming
 * @since 2019 /08/20 14:47:16
 */
public enum ChannelTypeEnum {

    /**
     * values
     */
    ZQ(1, "政企渠道"),
    PT(2, "平台渠道"),
    CJ(3, "厂家渠道"),
    ZY(4, "自有渠道"),
    TG(5, "推广渠道"),
    SP(6, "服务商渠道"),
    GR(7, "个人渠道"),;

    /**
     * 政企
     */
    public static final int CONSTS_ZQ = 1;
    /**
     * 平台
     */
    public static final int CONSTS_PT = 2;
    /**
     * 厂家
     */
    public static final int CONSTS_CJ = 3;
    /**
     * 自有
     */
    public static final int CONSTS_ZY = 4;
    /**
     * 推广
     */
    public static final int CONSTS_TG = 5;
    /**
     * 服务商
     */
    public static final int CONSTS_SP = 6;
    /**
     * 个人
     */
    public static final int CONSTS_GR = 7;

    private Integer code;
    private String name;

    ChannelTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static ChannelTypeEnum of(Integer code) {
        if(code == null){
            return null;
        }
        switch (code) {
            case 1:
                return ZQ;
            case 2:
                return PT;
            case 3:
                return CJ;
            case 4:
                return ZY;
            case 5:
                return TG;
            case 6:
                return SP;
            case 7:
                return GR;
            default:
                return null;
        }
    }

    public static String getName(Integer code) {
        ChannelTypeEnum of = of(code);
        return of == null ? null : of.getName();
    }

    public static ChannelTypeEnum[] enables() {
        return new ChannelTypeEnum[]{PT, TG, ZY, ZQ, CJ, SP, GR};
    }

    public static ChannelTypeEnum[] list() {
        return new ChannelTypeEnum[]{PT, TG, ZY, ZQ, GR};
    }
}
